//
//  QuDanHomeViewCell.m
//  QuDanOEM
//
//  Created by mac on 2021/10/23.
//

#import "QuDanHomeViewCell.h"

@implementation QuDanHomeViewCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    self.iconImg.layer.cornerRadius = 45/2;
    self.iconImg.layer.masksToBounds = YES;
    self.otherView.layer.cornerRadius = 4.0f;
    self.otherView.layer.masksToBounds = YES;
    self.otherView.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(170, 30) direction:PageGradientChangeDirectionLevel startColor:PostColorP(0xDBDCFF,1) endColor:PostColorP(0xEFF0FF,0.5)];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (void)setItemModel:(QuDanHomeRecordsItem *)itemModel
{
    _itemModel = itemModel;
    [self.iconImg sd_setImageWithURL:[NSURL URLWithString:itemModel.imageUrl] placeholderImage:[UIImage imageNamed:@"qd_test"]];
    self.nameLab.text = itemModel.nickName;
    self.addressLab.text = [NSString stringWithFormat:@"来自于%@",itemModel.area];
    self.contentLab.text = [NSString stringWithFormat:@"%@",itemModel.otherDesc];
    self.typeLab.text = [NSString stringWithFormat:@"%@",itemModel.category];
    self.priceLab.text = [NSString stringWithFormat:@"%.0f",[itemModel.price floatValue]];
    if (itemModel.imgs.count > 0) {
        self.ImageContainer.hidden = NO;
        if (itemModel.imgs.count == 1) {
            self.firstImg.hidden = NO;
            self.secondImg.hidden = YES;
            self.thirdImg.hidden = YES;
            [self.firstImg sd_setImageWithURL:[NSURL URLWithString:itemModel.imgs[0]] placeholderImage:[UIImage imageNamed:@"qd_test"]];
        }else if(itemModel.imgs.count == 2){
            self.firstImg.hidden = NO;
            self.secondImg.hidden = NO;
            self.thirdImg.hidden = YES;
            [self.firstImg sd_setImageWithURL:[NSURL URLWithString:itemModel.imgs[0]] placeholderImage:[UIImage imageNamed:@"qd_test"]];
            [self.secondImg sd_setImageWithURL:[NSURL URLWithString:itemModel.imgs[1]] placeholderImage:[UIImage imageNamed:@"qd_test"]];
        }else{
            self.firstImg.hidden = NO;
            self.secondImg.hidden = NO;
            self.thirdImg.hidden = NO;
            [self.firstImg sd_setImageWithURL:[NSURL URLWithString:itemModel.imgs[0]] placeholderImage:[UIImage imageNamed:@"qd_test"]];
            [self.secondImg sd_setImageWithURL:[NSURL URLWithString:itemModel.imgs[1]] placeholderImage:[UIImage imageNamed:@"qd_test"]];
            [self.thirdImg sd_setImageWithURL:[NSURL URLWithString:itemModel.imgs[2]] placeholderImage:[UIImage imageNamed:@"qd_test"]];
        }
    }else{
        self.ImageContainer.hidden = YES;
    }
}
@end
